/*
Janet Putnam
CS 362
Assignment 3
Card Test 2 - Unit Test of great hall card
Because of card was not refactored, this card can be accessed via a call to the cardEffect() function only.

Include the following lines in make file:

cardtest2:  cardtest2.c dominion.o rngs.o
	gcc -o cardtest2 -g cardtest2.c dominion.o rngs.o $(CFLAGS)

*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>

int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus);

int greatHallTest(int print_pass)
{
	//set random values
	int result;
	int check;
	int action_check;
	//setup initial struct gameState
	struct gameState G;
	
	memset(&G, 0, sizeof(struct gameState));
	
	//select cards in game
	int k[10] = {great_hall, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	//initialize gameState struct
	initializeGame(2, k, 4, &G);
	
	G.whoseTurn=0;
	G.hand[0][0] = great_hall;
	check = G.handCount[0];
	action_check = G.numActions;
	
	//test great hall inside cardEffect function
	result = cardEffect(0, 0, 0, 0, &G, 0, 0);
	if(result == 0)
	{
		if (print_pass == 0)
		{
			printf("PASS:  Great hall within CardEffect function ended without error.\n");
		}
	}
	else
	{
		printf("FAIL:  Great hall within CardEffect function ended with error.\n");
	}
	
	
	if((G.handCount[0] + 1) == check)
	{
		if (print_pass == 0)
		{
			printf("PASS:  Great hall within CardEffect function added 1 card to hand.\n");
		}
	}
	else
	{
		printf("FAIL:  Great hall within CardEffect function did not add 1 cards to hand.\n");
	}
	
	if((G.numActions + 1) == action_check)
	{
		if (print_pass == 0)
		{
			printf("PASS:  Great hall within CardEffect function added 1 action.\n");
		}
	}
	else
	{
		printf("FAIL:  Great hall within CardEffect function did not add 1 action.\n");
	}
		
	return 0;


}


int main(int argc, char **argv)
{	
	int print_pass;
	//if print_pass = 0, then results will print for passing tests.
	//if print_pass = 1, then results will not print for passing tests.
	//regardless of print_pass state, failing tests will print results.
	
	print_pass = atoi(argv[1]);
	if ((print_pass != 1 ) || (print_pass != 0))
	{
		print_pass = 0;
	}
	
	greatHallTest(print_pass);
	return 0;
}